﻿<%@ Page Language="C#" MasterPageFile="~/InventoryTracker/MasterPage.master" AutoEventWireup="true" CodeFile="NewGV.aspx.cs" Inherits="InventoryTracker_NewGV" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="maincontent" Runat="Server">

<div id="projectreport">
        <a name="content_start0" id="content_start0"></a>
        <fieldset style="height: 706px">
            <h2 class="none">
                Grid</h2>
            <legend>Grid</legend>
            <div class="formsection">
                Grid</div>
               
               <table>
               <tr>
               <td>
               <p >
                <asp:DropDownList ID="ddrInvoiceNumber" runat="server" 
                 style="top: 118px; left: 79px; position: absolute; height: 10px; width: 128px"></asp:DropDownList>
               <asp:Label ID="lblInvoiceNumber" runat="server" Text="Invoice Number"></asp:Label>
               </p>
              
                       </td>
                   </tr>
               </table>
               
               
               <div align="center">
<table>
<tr><th>Name:</th>
<td>
    <asp:DropDownList ID="DropDownList3" runat="server" 
        DataSourceID="SqlDataSource2" DataTextField="ItemCode" 
        DataValueField="ItemCode"></asp:DropDownList>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:TimeTrackerConnectionString %>" 
        SelectCommand="SELECT [ItemCode] FROM [MaterialMaster]"></asp:SqlDataSource>
</td>
</tr>
<tr><th>City:</th><td><asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
    
    </td></tr></table>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            CellPadding="4" ForeColor="#333333" 
            GridLines="None" DataSourceID="NewGvDS" DataKeyNames="InvoiceNumber"
            OnRowDataBound="GridView1_RowDataBound" 
            OnRowCommand="GridView1_RowCommand" OnRowUpdating="GridView1_RowUpdating" 
            AllowSorting="True" AllowPaging="True" PageSize="4" Height="236px" 
            style="top: 271px; left: 17px; position: absolute; width: 723px" 
                       >
            <Columns>                
                <asp:ButtonField Text="SingleClick" CommandName="SingleClick" Visible="False"/>
                <asp:TemplateField HeaderText="Item Code" SortExpression="Item Code">
                    <ItemTemplate>
                       <asp:Label ID="ItCodeLabel" runat="server" ></asp:Label>
                         <asp:DropDownList ID="ItCode" runat="server" Visible="False" 
                            AutoPostBack="True" CausesValidation="True" DataSourceID="ItemCodeDs" 
                            DataTextField="ItemCode" DataValueField="ItemCode" ></asp:DropDownList>
                         <asp:SqlDataSource ID="ItemCodeDs" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                            SelectCommand="SELECT [ItemCode] FROM [MaterialMaster]"></asp:SqlDataSource>
                     </ItemTemplate>               
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Item Name" SortExpression="ItemName">
                    <ItemTemplate>
                        <asp:Label ID="ItNameLabel" runat="server" Text='<%# Eval("InvoiceItem") %>'></asp:Label>
                        <asp:DropDownList ID="ItName" runat="server" Visible="False" 
                            AutoPostBack="True" CausesValidation="True" DataSourceID="ItemNameDs" 
                            DataTextField="ItemName" DataValueField="ItemName">
                            <asp:ListItem>-Select-</asp:ListItem>
                            <asp:ListItem>Andy</asp:ListItem>
                            <asp:ListItem>Betty</asp:ListItem>
                            <asp:ListItem>Conor</asp:ListItem>
                            <asp:ListItem>Declan</asp:ListItem>
                            <asp:ListItem>Eamon</asp:ListItem>
                            
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="ItemNameDs" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                            SelectCommand="SELECT [ItemName] FROM [MaterialMaster]"></asp:SqlDataSource>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Unit Rate" SortExpression="InvoiceItemRate">
                    <ItemTemplate>
                        <asp:Label ID="UnitRateLabel" runat="server" Text='<%# Eval("InvoiceItemRate") %>'></asp:Label>
                        <asp:DropDownList ID="UnitRate" runat="server" Visible="False" 
                            AutoPostBack="True" CausesValidation="True" DataSourceID="UnitRateDs" 
                            DataTextField="SellingRate" DataValueField="SellingRate">
                            <asp:ListItem>-Select-</asp:ListItem>
                            <asp:ListItem>4</asp:ListItem>
                            <asp:ListItem>5</asp:ListItem>
                            <asp:ListItem>3</asp:ListItem>
                            <asp:ListItem>7</asp:ListItem>
                            <asp:ListItem>8</asp:ListItem>
                            
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="UnitRateDs" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                            SelectCommand="SELECT [SellingRate] FROM [MaterialMaster]">
                        </asp:SqlDataSource>
                    </ItemTemplate>
                </asp:TemplateField>
                
                <asp:TemplateField HeaderText="Quantity" SortExpression="Tax">
                    <ItemTemplate>
                        <asp:Label ID="ItemQtyLabel" runat="server" Text='<%# Eval("InvoiceItemQty") %>'></asp:Label>
                        <asp:TextBox ID="ItemQty" runat="server" Text='<%# Eval("InvoiceItemQty") %>' Width="175px" visible="false"></asp:TextBox>
                        
                    </ItemTemplate>
                </asp:TemplateField>
                
                <asp:TemplateField HeaderText="Tax" SortExpression="Tax">
                    <ItemTemplate>
                        <asp:Label ID="TaxLabel" runat="server" Text='<%# Eval("Tax") %>'></asp:Label>
                        <asp:DropDownList ID="Tax" runat="server" Visible="False" AutoPostBack="true" CausesValidation="true">
                            <asp:ListItem>-Select-</asp:ListItem>
                            <asp:ListItem>VAT-12.5%</asp:ListItem>
                            <asp:ListItem>VAT-13%</asp:ListItem>
                            <asp:ListItem>VAT-10%</asp:ListItem>
                            <asp:ListItem>VAT-5%</asp:ListItem>
                            <asp:ListItem>VAT-0%</asp:ListItem>
                        </asp:DropDownList>
                    </ItemTemplate>
                </asp:TemplateField>
                
                <asp:TemplateField HeaderText="Discount" SortExpression="Tax">
                    <ItemTemplate>
                        <asp:Label ID="InvoiceDiscountLabel" runat="server" Text='<%# Eval("InvoiceDiscount") %>'></asp:Label>
                        <asp:TextBox ID="InvoiceDiscount" runat="server" Text='<%# Eval("InvoiceDiscount") %>' Width="175px" visible="false"></asp:TextBox>
                        
                    </ItemTemplate>
                </asp:TemplateField>
                
                
                <asp:TemplateField HeaderText="Total Amount" SortExpression="Tax">
                    <ItemTemplate>
                        <asp:Label ID="InvoiceTotalAmountLabel" runat="server" Text='<%# Eval("InvoiceTotalAmount") %>'></asp:Label>
                        <asp:TextBox ID="InvoiceTotalAmount" runat="server" Text='<%# Eval("InvoiceTotalAmount") %>' Width="175px" visible="false"></asp:TextBox>
                        
                    </ItemTemplate>
                </asp:TemplateField>
                
                <asp:TemplateField HeaderText="Date" SortExpression="Tax">
                    <ItemTemplate>
                        <asp:Label ID="InvoiceDateLabel" runat="server" Text='<%# Eval("InvoiceDate") %>'></asp:Label>
                        <asp:TextBox ID="InvoiceDate" runat="server" Text='<%# Eval("InvoiceDate") %>' Width="175px" visible="false"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                
                
            </Columns>
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle CssClass="headerStyle" ForeColor="White" BackColor="#5D7B9D" 
                Font-Bold="True" />
            <RowStyle CssClass="rowStyle" BackColor="#F7F6F3" ForeColor="#333333" />
            <EditRowStyle BackColor="#999999" />
            <AlternatingRowStyle CssClass="alternatingRowStyle" BackColor="White" 
                ForeColor="#284775" />
            <FooterStyle CssClass="footerStyle" BackColor="#5D7B9D" Font-Bold="True" 
                ForeColor="White" />
            <PagerStyle CssClass="pagerStyle" ForeColor="White" BackColor="#284775" 
                HorizontalAlign="Center" />
        </asp:GridView>



                
                   <asp:SqlDataSource ID="SqlDataSource1new" runat="server"></asp:SqlDataSource>



                
</div>
                

<div>        



                
        <asp:SqlDataSource ID="NewGvDS" runat="server" 
            ConnectionString="<%$ ConnectionStrings:TimeTrackerConnectionString %>" 
            DeleteCommand="DELETE FROM InvoiceDetails WHERE (InvoiceNumber = @InvoiceNumber)" 
            InsertCommand="INSERT INTO InvoiceDetails(InvoiceItem, InvoiceItemRate, Tax, InvoiceTotalAmount, InvoiceDate, InvoiceItemQty, InvoiceDiscount) VALUES (@InvoiceItem, @InvoiceItemRate, @Tax, @InvoiceTotalAmount, @InvoiceDate, @InvoiceItemQty, @InvoiceDiscount)" 
            SelectCommand="SELECT InvoiceDetails.* FROM InvoiceDetails" 
            UpdateCommand="UPDATE InvoiceDetails SET InvoiceItem = @InvoiceItem, InvoiceItemRate = @InvoiceItemRate, Tax = @Tax, InvoiceTotalAmount = @InvoiceTotalAmount, InvoiceItemQty = @InvoiceItemQty, InvoiceDiscount = @InvoiceDiscount WHERE (InvoiceNumber = @InvoiceNumber)">
            <DeleteParameters>
                <asp:Parameter Name="InvoiceNumber" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="InvoiceItem" />
                <asp:Parameter Name="InvoiceItemRate" />
                <asp:Parameter Name="Tax" />
                <asp:Parameter Name="InvoiceTotalAmount" />
                <asp:Parameter Name="InvoiceItemQty" />
                <asp:Parameter Name="InvoiceDiscount" />
                <asp:Parameter Name="InvoiceNumber" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="InvoiceItem" />
                <asp:Parameter Name="InvoiceItemRate" />
                <asp:Parameter Name="Tax" />
                <asp:Parameter Name="InvoiceTotalAmount" />
                <asp:Parameter Name="InvoiceDate" />
                <asp:Parameter Name="InvoiceItemQty" />
                <asp:Parameter Name="InvoiceDiscount" />
            </InsertParameters>
        </asp:SqlDataSource>
                
        <br /><br />
        
     </div>



                
                <div class="formsection">
                <asp:Button ID="btnCustSubmit" runat="server"  Text="Submit"/>
                    <asp:Label ID="lblResult" runat="server"></asp:Label>
            </div>


<asp:Label ID="Message" runat="server" Text=""></asp:Label>
               

               
               

               
               
                

               

            <asp:DropDownList ID="DropDownList4" runat="server" 
                DataSourceID="SqlDataSource3" DataTextField="ItemName" 
                DataValueField="ItemName">
            </asp:DropDownList>
            <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                ConnectionString="<%$ ConnectionStrings:TimeTrackerConnectionString %>" 
                SelectCommand="SELECT [ItemName] FROM [MaterialMaster]"></asp:SqlDataSource>
               

               
               

               
               
                

               

        </fieldset>
    </div>

</asp:Content>

